<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Validators\AuthValidator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('admin/home');
    }

    public function getLogin()
    {
        return view("admin/login");
    }

    public function postLogin(Request $request, AuthValidator $validator)
    {
        $input = $request->all();

        $validator->with($input)->passesOrFail("login");

        if (Auth::guard('admin')->attempt(['account' => $input["account"], 'password' => $input["password"]])) {
            echo 'asdf';
        } else {
            echo "222";
        }

        return $this->successResponse(["haha" => [1, 2, 3, 3], "redirect_href" => url("/admin/index")]);
    }

    public function getPassword(Request $request)
    {
        $str = $request->input('str');

        echo $str;

        echo "<br>";

        echo bcrypt($str);
    }
}
